package com.securitytrace.client.productlistener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ProductListenerController implements ActionListener {

	private ProductActionListener productActionListener;

	public ProductListenerController(ProductActionListener productActionListener) {
		this.productActionListener = productActionListener;
	}
	
	@Override
	public void actionPerformed(ActionEvent event) {
		String methodName = event.getActionCommand();
		try {
			Method excuteMethod = productActionListener.getClass().getDeclaredMethod(methodName, new Class<?>[]{});
			excuteMethod.invoke(productActionListener, new Object[]{});
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		
	}

}
